home *** CD-ROM | disk | FTP | other *** search
- /*
- File: TranscriptWindow.h
-
- Copyright: © 1991-1994 by Apple Computer, Inc.
- All rights reserved.
-
- Part of the AOCE Sample SMSAM Package. Consult the license
- which came with this software for your specific legal rights.
-
- */
-
-
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
-
- #ifndef __WINDOWS__
- #include <Windows.h>
- #endif
-
- #ifndef __MEMORY__
- #include <Memory.h>
- #endif
-
- #ifndef __LIMITS__
- #include <Limits.h>
- #endif
-
- #ifdef __UNIVERSAL__
- #ifndef __LOWMEM__
- #include <LowMem.h>
- #endif
- #else
- #ifndef __SYSEQU__
- #include <SysEqu.h>
- #endif
- #endif
-
- #ifndef __EVENTS__
- #include <Events.h>
- #endif
-
- #ifndef __OSEVENTS__
- #include <OSEvents.h>
- #endif
-
- #ifndef __STDIO__
- #include <stdio.h>
- #endif
-
- /***********************************|****************************************/
-
- const short kHMargin = 5;
- const short kVMargin = 10;
- const short kForceDepth = 16;
-
- enum { forceUnchanged, forceOn, forceOff };
-
- typedef struct ForceState {
- Boolean toWindow;
- Boolean toFile;
- } ForceState;
-
- /***********************************|****************************************/
-
- class TTranscriptWindow : public TDirectObject
- {
- public: TTranscriptWindow ( short windowID );
- ~TTranscriptWindow ( );
-
- // Call this to initialize the globals
- void Init(short numLines, short numCharsPerLine);
-
- // Pass this routine an event, and it will check whether that event
- // 'belongs' to this debug window. If it does, then it will handle the
- // event and return true; otherwise it will return false.
- Boolean Event(EventRecord *anEvent);
-
- // If you call this, then subsequent writelns will be sent to the indicated file. (Assuming
- // writing to the file is enabled. Pass '' for the fileName to close any open file.
- OSErr Redirect (short vRefnum, long dirID, Str255 fileName, Boolean append = false );
- OSErr Redirect (const FSSpec& redirectFile, Boolean append );
-
- void Show (void);
-
- // Since it is now possible that one part of the program disables writelns to the window, you
- // might want to guarantee that certain writelns appear in the window. ForceOutput saves
- // the values of gWrToWindow & gWrToFile on a stack (depth = kForceDepth), and sets
- // these values according to the parameters. EndForce simply pops the stack.
- void ForceOutput(short wrToWindow, short wrToFile);
- void EndForce();
-
-
-
- void Append (Ptr textBuf, long byteCount);
-
- /* Call before SizeWindow if you need to resize the debug window programmatically*/
- void InvalGrowBox();
-
- /* Call after SizeWindow if you need to resize the debug window programmatically*/
- void Grown();
-
- // Call the following procedures in response to events for the WriteLnWindow.
- // (Test the window receiving the event against gDebugWindowPtr.
-
- void ActivateEvent(short modifiers);
- void MouseDown(short where, Point pt, short modifiers);
- void UpdateEvent();
- void Scroll(short howManyLines); /* for UTrace use; negative arg scrolls backwards*/
-
- void FlushOutputFile(void);
-
- void WindowFocus(void);
- void ContentFocus(void);
- long BaseLine(short ln) ;
-
- void DoScrolling(void);
-
- void Draw (void) const;
- void Draw ( const Rect& rectToRedraw ) const;
-
- void NewLine(void);
- void ShowPoint(Point pt);
-
- void AddEncodedText (Ptr dataPtr, long size);
- void AddHexData (Ptr dataPtr, short dataSize );
-
- static Boolean IsLogWindowEvent ( const EventRecord& event );
- friend pascal void TrackControlCallback ( ControlHandle aControl, short partCode );
- WindowPtr GetWindowPtr () const;
-
-
- protected:
-
- Boolean Initialize ( );
- Boolean InitializeFontInfo ();
-
- short fWindowResID ;
-
- WindowPtr fDebugWindowPtr;
- long fLines;
- short fPerLine; // number of characters per line
- long fTotal; // number of characters in all lines together
- char** fText; // the ring buffer: blanks pad each line to 80 chars
- short** fLineLens; /* # of real characters in each line; (*gLinesLens)^[0]
- is # of characters in the line that begins with
- (*fText)^[0] */
-
- long fFirst; // where in the ring buffer the top line starts
- long fLast; // where in the ring buffer the bottom line starts
- short fPos; // number of characters so far in the bottom line
-
- TextStyle fFaceInfo;
- FontInfo fFontInfo;
- short fHeigth;
-
- ControlHandle fSBars[2]; // the window scroll bars
- Point fScrollOffset; // the position to which we are scrolled
- Point fViewSize; // total view size
- Point fEndOfText; // the pen position after drawing all the lines
-
- Rect fStdDrag;
- Rect fStdSize;
- RgnHandle fARgn;
-
- Boolean fGotRefNum;
- short fRefNum; // refNum for redirect output
- short fVRefNum; // likewise, vrefNum
-
- ForceState fForceStack[kForceDepth];
- short fForcePtr;
-
- Boolean fScrollWindowWhenTextIsAdded;
- Boolean fWrToWindow;
- Boolean fWrToFile;
-
- Boolean fDirty; // whether unflushed data has been written.
- };
-
- /***********************************|****************************************/
-